package com.gouaixin.bee.beeframework2.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.gouaixin.bee.beeframework2.R;
import com.gouaixin.bee.beeframework2.tool.mLog;

/**
 * Created by Administrator on 2015/3/10.
 */
//缘分红娘
public class B16_yuanfenHongniangyueActivity extends Activity {
    Context context=B16_yuanfenHongniangyueActivity.this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.b16_yuanfenhongniang);
        
        initHead();
        initContent();

    }

    /***
     * 内容区域的监听
     */
    private void initContent() {
        WebView webView= (WebView) findViewById(R.id.webview);

        //发现分类的网页视图
        WebSettings webSetting = webView.getSettings();
        webSetting.setJavaScriptEnabled(true);
        webSetting.setUseWideViewPort(true);
        webView.requestFocus();
        webView.loadUrl("http://jiekou.hydgyx.com/renzheng.html");

        //设置Web视图
        webView.setWebViewClient(new HelloWebViewClient());

    }

    /***
     * 头部的监听
     */
    private void initHead() {
        //顶部
        ImageView back;//返回
        TextView title;//标题

        back= (ImageView) findViewById(R.id.back);
        title= (TextView) findViewById(R.id.title);

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }


    //Web视图
    private class HelloWebViewClient extends WebViewClient {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode,
                                    String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            //在这里载入页面。
            view.loadUrl("http://jiekou.hydgyx.com/renzheng.html");
        }


        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            mLog.e("红娘认证：" + url);



            view.loadUrl("http://jiekou.hydgyx.com/renzheng.html");
            return false;

        }
    }

    @Override
    public void onBackPressed() {
        Intent mainIntent = new Intent().setClass(context, MyMainActivity.class);
        startActivity(mainIntent);
        finish();
    }
}
